package crypt_kicker_II;

import java.util.*;
import java.io.*;

/*
 * Problem ID: 110304 
 * Algorithm: 
 * If we can assume that the sentence: "the quick brown fox jumps over the lazy dog" 
 * will be part of the solution, then we can easily traverse through 
 * the input and and find the proper mapping. After the rest of the problem becomes trivial.
 */
class Main implements Runnable
{
	 static String ReadLn(int maxLength) 
	    {
	        byte line[] = new byte[maxLength];
	        int length = 0;
	        int input = -1;
	        try {
	            while (length < maxLength) {
	                input = System.in.read();
	                if ((input < 0) || (input == '\n'))
	                    break;
	                line[length++] += input;
	            }

	            if ((input < 0) && (length == 0))
	                return null;
	            return new String(line, 0, length);
	        } catch (IOException e) {
	            return null;
	        }
	    }
	 
	 public static void main(String [] args)
	 {
		 Main stuff = new Main();
		 stuff.run();
	 }
	 
	 public void run()
	 {
		new CryptKickMe().run(); 
	 }
}

class CryptKickMe implements Runnable
{
	private static final int MAX_LENGTH = 1024;
	
	public void run()
	{
		ArrayList<String> encryptionList;
		boolean isFound = false;
		String encryption;
		HashMap<String, String> initMapping;
		
		int numOfCases = Integer.parseInt(Main.ReadLn(MAX_LENGTH).trim());
		String init = "the quick brown fox jumps over the lazy dog";
		
		Main.ReadLn(MAX_LENGTH);
		int counter = 0;
		
		for (int i = 0; i < numOfCases; i++)
		{	
			encryptionList = new ArrayList<String>();
			isFound = false;
			
			while ((encryption = Main.ReadLn(MAX_LENGTH)) != null)
			{	
				if (encryption.equals("\r"))
				{
					break;
				}
				
				encryptionList.add(encryption.trim());
			}
			
			for (int j = 0; j < encryptionList.size(); j++)
			{
				encryption = encryptionList.get(j);
				
				if (matches(init, encryption) == true)
				{
					initMapping = createInitMapping(encryption);
					boolean result = verifyMapping(init, encryption, initMapping);
					
					if (result == true)
					{
						isFound = true;
						cryptKickMe(encryptionList, initMapping);
						break;
					}
				}
			}
			
			if (isFound == false)
			{
				System.out.println("No solution.");
			}
			
			if (i < numOfCases - 1)
			{
				System.out.println();
			}
		}
		while (Main.ReadLn(MAX_LENGTH) != null);
	}
	
	public void cryptKickMe(ArrayList<String> encryptionList, HashMap<String, String> initMapping)
	{
		String result = "";
		
		for (int i = 0; i < encryptionList.size(); i++)
		{
			String encrypt = encryptionList.get(i);
			
			for (int j = 0; j < encrypt.length(); j++)
			{
				String encryptWordLetter = encrypt.charAt(j) + "";
				
				if (encryptWordLetter.equals(" "))
				{
					result += " ";
				}
				else
				{
					String value = initMapping.get(encryptWordLetter);
					
					result += value;
				}
			}
			
			System.out.println(result.trim());
			result = "";
		}
	}
	
	public HashMap<String, String> createInitMapping(String word)
	{
		HashMap<String, String> temp = new HashMap<String, String>();
		
		for (int i = 0; i < word.length(); i++)
		{
			String letter = word.charAt(i) + "";
			
			if (!letter.equals(" "))
			temp.put(letter, "");
		}
		
		return temp;
	}
	
	public boolean matches(String init, String encryption)
	{
		boolean done = false;
		boolean matches = false;
	
		while (done == false)
		{
			int initBlankLoc = init.indexOf(" ");
			int encryptBlankLoc = encryption.indexOf(" ");
			
			if (initBlankLoc == -1 && encryptBlankLoc == -1)
			{
				if (init.length() == encryption.length())
				{
					matches = true;
				}
				break;
			}
			else if (initBlankLoc != encryptBlankLoc)
			{
				break;
			}
					
			init = init.substring(initBlankLoc).trim();
			encryption = encryption.substring(encryptBlankLoc).trim();
		}
		
		return matches;
	}
	
	public boolean verifyMapping(String initWord, String encryptWord, HashMap<String, String> temp)
	{
		for (int i = 0; i < encryptWord.length(); i++)
		{
			String initLetter = initWord.charAt(i) + "";
			String encryptLetter = encryptWord.charAt(i) + "";
			
			if (!encryptLetter.equals(" "))
			{
				String initValue = temp.get(encryptLetter);
				
				if (initValue.equals(""))
				{
					temp.put(encryptLetter, initLetter);
				}
				else if (!initValue.equals(initLetter))
				{
					temp.clear();
					return false;
				}
			}
		}
		return true;
	}
}